package cn.edu.ujs.coor.repository.item;

import cn.edu.ujs.coor.model.Item;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 提交项
 *
 * @author 柳曾雄
 * @date 2018-08-14
 */
@Repository
public interface ItemRepository extends JpaRepository<Item, String>, JpaSpecificationExecutor<Item> {

    /**
     * 根据项目编号查询
     * @param projectId
     * @return
     */
    List<Item> findByProjectId(String projectId);

    /**
     * 用户项目编号和用户编号查询
     * @param projectId
     * @param userId
     * @return
     */
    Item findByProjectIdAndUserId (String projectId, String userId);

    /**
     * 根据项目编号查询
     * @param projectId
     * @return
     */
    @Query(value = "select content from coor_item where project_id = ?1", nativeQuery = true)
    List<String> findContentByProjectId (String projectId);
}
